using System.Data;
using System.Data.SqlClient;
using Provausio.Common.Data;
using Provausio.Common.Objects;

namespace TrainingManagement.api.Models.Data.CRUD.Skill
{
    public class SkillUpdateDataSource : NonQuerySource<BusinessObjects.Skill>
    {
        public override bool Execute(BusinessObjects.Skill request)
        {
            const string updateSkill = "dbo.training_api_SkillUpdate";
            var parameters = new SqlParameter[3];
            parameters[0] = new SqlParameter("@Title", SqlDbType.NVarChar){Value = request.Title};
            parameters[1] = new SqlParameter("@DocID", SqlDbType.Int) {Value = request.DocId};
            parameters[2] = new SqlParameter("@SkillID", SqlDbType.Int){Value = request.SkillId};

            return SqlHelper.ExecuteNonQuery(
                    ConnectionStrings.TrainingDb,
                    CommandType.StoredProcedure,
                    updateSkill,
                    parameters) != 0;
        }
    }
}